/*
 * @Descripttion: 供应商接口
 * @version:
 * @Author: 穆宏宇
 * @Date: 2020-09-22 18:38:07
 * @LastEditors: 穆宏宇
 * @LastEditTime: 2020-11-06 11:23:41
 */

import api from './index'
import config from "@/config"


// 获得商品目录Ztree异步树
export const queryGodCategoryZtreeAsyn = (parentId,v) => {
  const params = {
    parentId:parentId,
    v:v
  }
  // const url = `/api/category/queryGodCategoryZtreeAsyn`
  const url = `/vapi/index/system/category/queryGodCategoryZtreeAsyn`
  return api.get(url,params)
}

// 供应商查询商品列表
export const goodsItemManageList = (data) => {
  const url = `/api/goodsItem/manage/list`
  // const url = `/api/goodsItem/manage/listForManage`
  return api.get(url,data)
}

// 查询商品上下架历史记录
export const itemStateHisList = (fkItemId,data) => {
  const url = `/api/itemStateHis/queryList/${fkItemId}`
  return api.get(url,data)
}

// 商品临时下架
export const postGoodsState = (fkItemId,goodsState ) => {
  const url = `/api/goodsItem/manage/goodsState?goodsState=${goodsState}`
  const param = [fkItemId];
  return api.post(url,param)
}

// 项目报名列表
export const certificateList = (data) => {
  const url = `/api/purchaseProSuppliersCertificate/proCertificatePageList`
  return api.get(url,data)
}

// 项目报名
export const postPurchaseProSuppliersCertificate = (data) => {
  const url = `/api/purchaseProSuppliersCertificate/`
  return api.post(url,data)
}

// 查询指定主键的资质详情
export const getPurchaseDetailById = (id) => {
  const url = `/api/purchaseProSuppliersCertificate/getDetailById/${id}`
  return api.get(url)
}

// 修改项目报名
export const putPurchaseProSuppliersCertificate = (data) => {
  const url = `/api/purchaseProSuppliersCertificate/`
  return api.put(url,data)
}
// 项目基本信息
export const queryProOrderInfo = (projectId) => {
  const url = `/api/tPurchaseProProjects/queryProOrderInfo/${projectId}`
  return api.get(url)
}

// 查询项目距离报名时间
export const querySecondTime = (data) => {
  const url = `/api/tPurchaseProProjects/querySecondTime`
  return api.get(url,data)
}

// 查询项目询价列表
export const pageQuerySupplierBiddingProjectsList = (data) => {
  // const url = `/api/tPurchaseProProjects/pageQuerySupplierBiddingProjectsList`
  const url = '/api/tPurchaseProProjects/pageSupplierBiddingProjectsList'
  return api.get(url,data)
}

// 分页查询承运商本人项目报价历史列表
export const queryPageProBiddingList = (params) => {
  const url = `/api/tPurchaseBidBidding/queryPageProBiddingList`
  return api.get(url,params)
}
// 询价排名列表
export const pageQueryProBiddingList = (data) => {
  const url = `/api/tPurchaseBidBidding/pageQueryProBiddingList`
  return api.get(url,data)
}

// 根据项目ID查询报价信息及报价详情
export const queryBiddingGoodsListByProject = (data) => {
  const url = `/api/tPurchaseBidBidding/queryBiddingGoodsListByProject`
  return api.get(url,data)
}
// 查询项目询价规则
export const getBiddingRules = (projectId) => {
  const url = `/api/tPurchaseProProjects/getBiddingRules/${projectId}`
  return api.get(url)
}

// 查询供应商项目个人询价记录
export const supBidBiddingQueryList = (params) => {
  const url = `/api/tPurchaseBidBidding/supBidBiddingQueryList`
  return api.get(url,params)
}

// 提交询价报价
export const doSaveBidBidding = (data) => {
  const url = `/api/tPurchaseBidBidding/doSaveBidBidding`
  return api.post(url,data)
}

// 订单跟踪：
export const queryProProcessCodeList = (params) => {
  const url = `/api/tPurchaseProcessCode/queryProProcessCodeList`
  return api.get(url,params)
}

// 查询供应商订单列表
export const getsupplierList = (params) => {
  const url = `/api/order/supplier/list`
  return api.get(url,params)
}

// 查询供应商订单详情
export const supplierOrderInfor = (data) => {
	debugger
	const url = `/vapi/shoporder/getInfoById`
	return api.post(url, data)
}

// 导出订单信息
export const exportOrder = (data) => {
  const url = `/api/order/supplier/export`
  return api.download(url,data)
}

// 查询订单详情 物流信息
export const orderLogistics = (orderId) => {
  const url = `/vapi/orderLogistics/${orderId}`
  return api.get(url)
}

// 同步订单状态
export const supplierSync = (eshopNumbers) => {
  const url = `/api/order/supplier/sync/${eshopNumbers}`
  return api.get(url)
}

// 导出物流模板
export const exportTemplate = (params) => {
  const url = `/api/orderLogistics/export`
  return api.download(url,params)
}

// 生成对账单列表页
export const reconciliationCreat = (data) => {
  const url = `/api/order/reconciliation/eshopSupplierList`
  return api.get(url,data)
}

// 同步供应商账单
export const reconciliationSupplierSync = (orderStartTime,orderEndTime) => {
  const url = `/api/order/reconciliation/supplierSync?orderStartTime=${orderStartTime}&orderEndTime=${orderEndTime}`
  return api.post(url)
}

// 查询商品库权限
export const queryAuthorityBySupplierId = () => {
  const url = `/api/maintenanceAuthority/queryAuthorityBySupplierId`
  return api.get(url)
}

// 查询供应商项目历史询价记录
export const bidBiddingHistoryQueryList = (param) => {
  const url = `/api/tPurchaseBidBidding/bidBiddingHistoryQueryList`
  return api.get(url,param)
}

// 导出对账单模板
export const exportReconciliation = () => {
  const url = `/api/order/reconciliation/example`
  return api.download(url)
}

// 导出同步供应商账单
export const exportCenterSync = (param) => {
  const url = `/api/order/reconciliation/exportCenterSync`
  return api.download(url,param)
}

// 查询商品库权限
export const queryItemPropertiesList = (categoryId,param) => {
  const url = `/api/property/queryList/${categoryId}`
  return api.get(url,param)
}

// 撤销询价
export const doRevokeBidbidding = (projectId) => {
  const url = `/api/tPurchaseBidBidding/doRevokeBidbidding/${projectId}`
  return api.put(url)
}

export const saveOrUpdateProducts = (data)=>{
  const url = `/api/goodsItem/manage/supplier`
  return api.post(url,data)
}

export const getSupplierGoodsInfo = (param)=>{
  const url = `/api/goodsItem/manage/supplier`
  return api.get(url,param)
}

// 查询询价次数
export const bidBiddingHistoryQueryCount = (projectId)=>{
  const url = `/api/tPurchaseBidBidding/bidBiddingHistoryQueryCount/${projectId}`
  return api.get(url)
}

// 品牌模糊搜索
export const queryListByNameShow = (param)=>{
  const url = `/api/brands/queryListByNameShow`
  return api.get(url,param)
}

// 获取询价列表
export const getProGoodsByOrderId = (orderId)=>{
  const url = `/api/tPurchaseProProjects/getProGoodsByOrderId/${orderId}`
  return api.get(url)
}


//修改本地供应商商品库存
export const updateGoodsItem = (data) => {
	const url = '/vapi/item/updateGoodsItem'
	return api.post(url,data)
}



// 导出订单--------导出工业品公司订单
export const getOrderExport = (params) => {
	let url = '/vapi/shoporder/exportsupplier'
	if (params) {
		url = url + '?'
		for (const key in params) {
			url = url + key + '=' + params[key] + '&'
		}
		url = url.substring(0, url.length - 1)
	}
	return api.download(url)
}



//打印订单
export const selectDetailInvoice = (data) => {
	const url = '/vapi/invoice/selectDetailInvoice'
	return api.post(url,data)
}

//打印顶动感修改
export const editInvoice = (data) => {
	const url = '/vapi/invoice'
	return api.post(url,data)
}

// 查询电商列表
export const getOnlineSupplierList = () => {
	const url = `${config.pre}/supplier/supplierAdmin/list`
	return api.get(url)
}

// 价格接口检测
export const getGoodsPrice = (params) => {
	const url = `${config.pre}/supplier/supplierAdmin/prices`
	return api.get(url, params)
}

// 库存接口检测
export const getGoodsStocks = (params) => {
	const url = `${config.pre}/supplier/supplierAdmin/stocks`
	return api.get(url, params)
}

// 商品详情接口检测
export const getGoodsDetail = (params) => {
	const url = `${config.pre}/supplier/supplierAdmin/goodsDetail`
	return api.get(url, params)
}

// 智能柜列表
export const smartCabinetList = params => {
	const url = `${config.pre}/supplier/smartCabinet/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`;
	return api.post(url, params)
}

// 根据id获取智能柜
export const smartCabinetId = id => {
	const url = `${config.pre}/supplier/smartCabinet/${id}`;
	return api.get(url)
}

// 更新智能柜
export const smartCabinetUpdate = data => {
	const url = `${config.pre}/supplier/smartCabinet/${data.id}`;
	return api.post(url, data)
}

// 更新智能柜状态
export const smartCabinetUpdateStatus = data => {
	const url = `${config.pre}/supplier/smartCabinet/status/${data.id}`;
	return api.post(url, data)
}

// 新增智能柜
export const smartCabinetAdd = data => {
	const url = `${config.pre}/supplier/smartCabinet/${data.id}`;
	return api.post(url, data)
}

// 智能柜状态
export const smartCabinetState = id => {
	const url = `${config.pre}/supplier/smartCabinet/status`;
	return api.get(url)
}

// 智能柜商品列表
export const smartCabinetGoodsList = params => {
	const url = `${config.pre}/supplier/smartCabinetGoods/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
	return api.post(url, params)
}

// 新增智能柜中的商品
export const smartCabinetGoodsAdd = params => {
	const url = `${config.pre}/supplier/smartCabinetGoods/add`
	return api.post(url, params)
}

// 移除一个智能柜中的商品
export const smartCabinetGoodsremove = id => {
	const url = `${config.pre}/supplier/smartCabinetGoods/${id}`
	return api.delete(url)
}



//供应商补打发货单
export const listHistoryByNo = (data) => {
	const url = `/vapi/invoice/listHistoryByNo`
	return api.post(url, data)
}

